//
//  View2Controller.m
//  Tupianliulanqi
//
//  Created by zzn on 2016/12/27.
//  Copyright © 2016年 zzn. All rights reserved.
//

#import "View2Controller.h"

@interface View2Controller ()<UIScrollViewDelegate>
{
    UIImageView *iv;
    UIScrollView *scro;
}
@end

@implementation View2Controller

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    scro = [[UIScrollView alloc]initWithFrame:self.view.bounds];
    scro.maximumZoomScale = 3;
    scro.minimumZoomScale = 1;
    scro.delegate = self;
    [self.view addSubview:scro];
    
    iv = [[UIImageView alloc]initWithImage:_image];
    iv.frame = scro.bounds;
    iv.contentMode = UIViewContentModeScaleAspectFit;
    iv.userInteractionEnabled = YES;
    UITapGestureRecognizer *ger = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onTap:)];
    [iv addGestureRecognizer:ger];
    [scro addSubview:iv];
}

- (void)onTap:(UITapGestureRecognizer *)tap
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    NSLog(@"nckl");
    return iv;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
